angular.module('loginApp', ['restangular', 'moti.services.loginService', 'directiveModule', 'moti.directive.modal'])
    .controller('loginCtrl', ['$scope', '$timeout', 'LoginInterface', '$modal', function($scope, $timeout, LoginInterface, $modal){
        $scope.loginForm = function(){
            if($scope.login_form.$valid){
                LoginInterface($scope.user).then(function(data){
                    localStorage.setItem("U_INFO", data.auth);
                    // localStorage.setItem("U_ID", data.admin.admin_id);
                    // localStorage.setItem("U_USERNAME", data.admin.username);
                    localStorage.setItem("U_NAME", data.name);
                    $modal({id : 'tip-modal', text : "登录成功，即将跳转..."}).show();
                    $timeout(function(){
                        location.href = PAGE_API.INDEX;
                    }, 1500);
                });
            }
        }
}]);